<template>
    <div>
        <div class="card card-custom gutter-b example example-compact" id="tableBody">
            <div class="card-header">
                <div class="card-title">
                    <span class="card-icon">
                        <i class="text-dark-50 flaticon-search-magnifier-interface-symbol"></i>
                    </span>
                    <h3 class="card-label"> 查询区域 </h3>
                </div>
                <div class="card-toolbar">
                    <div class="example-tools justify-content-center">
                        <!-- 
                <span data-toggle="tooltip" class="example-toggle"></span>
                <span data-toggle="tooltip" class="example-copy"></span> 
              -->
                    </div>
                </div>
            </div>
            <div class="card-body">
                <!--查询条件-->
                <div class="m-form m-form--fit m-form--label-align-left m-form--group-seperator-dashed">
                    <div class="m-portlet__body">
                        <div class="form-group m-form__group row">
                            <label class="col-form-label">任务名称：</label>
                            <div class="col-md-2">
                                <input type="text" class="form-control" v-model="searchForm.taskName" placeholder="请输入">
                            </div>
                            <label class="col-form-label">任务编码：</label>
                            <div class="col-md-2">
                                <input type="text" class="form-control" v-model="searchForm.taskId" placeholder="请输入">
                            </div>
                            <label class="col-form-label">节点编号：</label>
                            <div class="col-md-2">
                                <input type="text" class="form-control" v-model="searchForm.taskDefinitionKey"
                                    placeholder="请输入">
                            </div>
                            
                        </div>
                        <div class="form-group m-form__group row">
                            <label class="col-form-label">流程实例：</label>
                            <div class="col-md-2">
                                <input type="text" class="form-control" v-model="searchForm.instanceId" placeholder="请输入">
                            </div>
                            <label class="col-form-label">状态：</label>
                            <div class="col-md-2">
                                <el-select type="text" v-model="searchForm.suspended">
                                    <el-option
                                        v-for="item in [{ value: null, label: '请选择', value: true, label: '挂起' }, { value: false, label: '激活' }]"
                                        :key="item.value" :label="item.label" :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                            <label class="col-form-label">业务Key：</label>
                            <div class="col-md-2">
                                <input type="text" class="form-control" v-model="searchForm.businessKey" placeholder="请输入">
                            </div>
                            <label class="col-form-label">租户：</label>
                            <div class="col-md-2">
                                <input type="text" class="form-control" v-model="searchForm.tenantId" placeholder="请输入">
                            </div>
                        </div>
                        <div class="form-group m-form__group row">
                            <label class="col-form-label">任务类型：</label>
                            <div class="col-md-2">
                                <el-select type="text" v-model="searchForm.taskType">
                                    <el-option
                                        v-for="item in [{ value: '', label: '全部',},{ value: '0', label: '所属人' }, { value: '1', label: '经办人' }, { value: '2', label: '候选人' }, { value: '3', label: '组任务' }]"
                                        :key="item.value" :label="item.label" :value="item.value">
                                    </el-option>
                                </el-select>
                            </div>
                            <label class="col-form-label"  v-if="this.searchForm.taskType =='0'" >任务所属人：</label>
							<div class="col-md-3" v-if="this.searchForm.taskType =='0'">
								<div class="input-group">
									<input type="text" readonly class="form-control m-input" v-model='searchForm.ownerText' placeholder="请选择" aria-describedby="basic-addon2">
									<div class="input-group-append">
										<span style="cursor:pointer;" class="input-group-text" @click="resetApprover(0)">
											<i class="fa fa-times"></i>
										</span>
									</div>
									<div class="input-group-append">
										<span  style='cursor:pointer;' class="input-group-text" @click='initApprover(0)'>
											<i class="flaticon-user-ok"></i>
										</span>
									</div>
								</div>
							</div>
							<label class="col-form-label" id="transactorsLabel" v-if="this.searchForm.taskType =='1'">经办人：</label>
							<div class="col-md-3" v-if="this.searchForm.taskType =='1'">
								<div class="input-group">
									<input type="text" readonly class="form-control m-input" v-model='searchForm.transactorsText' placeholder="请选择" aria-describedby="basic-addon2">
									<div class="input-group-append">
										<span style="cursor:pointer;" class="input-group-text" @click="resetApprover(1)">
											<i class="fa fa-times"></i>
										</span>
									</div>
									<div class="input-group-append">
										<span  style='cursor:pointer;' class="input-group-text" @click='initApprover(1)'>
											<i class="flaticon-user-ok"></i>
										</span>
									</div>
								</div>
							</div>
							<label class="col-form-label"  v-if="this.searchForm.taskType =='2'">候选人：</label>
							<div class="col-md-3"  v-if="this.searchForm.taskType =='2'">
								<div class="input-group">
									<input type="text" readonly class="form-control m-input" v-model="searchForm.candidatesText" placeholder="请选择" aria-describedby="basic-addon2">
									<div class="input-group-append">
										<span style="cursor:pointer;" class="input-group-text" @click="resetApprover(2)">
											<i class="fa fa-times"></i>
										</span>
									</div>
									<div class="input-group-append">
										<span  style='cursor:pointer;' class="input-group-text" @click='initApprover(2)'>
											<i class="flaticon-user-ok"></i>
										</span>
									</div>
								</div>
							</div>
							<label class="col-form-label"  v-if="this.searchForm.taskType =='3'">组：</label>
							<div class="col-md-3" v-if="this.searchForm.taskType =='3'">
								<div class="input-group">
									<input type="text" readonly class="form-control m-input" v-model='searchForm.groupText' placeholder="请选择" aria-describedby="basic-addon2">
									<div class="input-group-append">
										<span style="cursor:pointer;" class="input-group-text" @click="resetApprover(3)">
											<i class="fa fa-times"></i>
										</span>
									</div>
									<div class="input-group-append">
										<span  style='cursor:pointer;' class="input-group-text" @click='initOrgWin(3)'>
											<i class="flaticon-user-ok"></i>
										</span>
									</div>
								</div>
							</div>
                            <b-button :pressed="false" variant="btn btn-primary font-weight-bold mr-2"
                                @click="search()"><span><i class="fa fa-search"></i><span>查询</span></span></b-button>
                            <b-button :pressed="false" variant="btn btn-light font-weight-bold mr-2" @click="resetAll()">
                                <span><span>清空条件</span></span></b-button>
                        </div>
                        

                    </div>
                    <!-- <div class="m-portlet__foot m-portlet__no-border m-portlet__foot--fit">
                        <div class="m-form__actions m-form__actions--solid">
                            <div class="row">
                                <div class="col m--align-left">
                                   
                                </div>
                                <div class="col m--align-right">

                                </div>
                            </div>
                        </div>
                    </div> -->
                </div>
            </div>
            <!--分页组件-->
            <el-table style="width: 100%" stripe border @selection-change="handleSelectionChange" highlight-current-row
                :data="dataList">
                <!-- 复选框 -->
                <el-table-column type="selection" width="40"></el-table-column>
                <el-table-column label="序号" min-width="50">
                    <template slot-scope="scope">
                        {{ scope.$index + 1 }}
                    </template>
                </el-table-column>
                <el-table-column align="left" prop="name" show-overflow-tooltip label="任务名称">
                    <template slot-scope="scope">
                        <b-badge class="mr-1" variant="dark">{{ scope.row.name }}</b-badge>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="owner" label="任务所属人" min-width="120"></el-table-column>
                <el-table-column align="center" prop="assignee" label="经办人" min-width="80"></el-table-column>
                <el-table-column align="left" prop="processTitle" show-overflow-tooltip label="隶属流程" min-width="120">
                    <template slot-scope="scope">
                        <b-badge class="mr-1" variant="info">{{ scope.row.processTitle }}</b-badge>
                    </template>
                </el-table-column>

                <el-table-column align="center" prop="businessKey" label="业务编码" min-width="150"></el-table-column>
                <el-table-column align="center" prop="version" label="版本" min-width="80">
                    <template slot-scope="scope">
                        <div class="symbol symbol-30 symbol-circle symbol-light-warning">
                            <span class="symbol-label font-size-h8">{{ scope.row.version }}</span>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="processInstanceId" label="流程实例" min-width="100">
                    <template slot-scope="scope">
                        <b-badge class="mr-1" variant="danger">{{ scope.row.processInstanceId }}</b-badge>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="taskId" label="任务编码" min-width="80">
                    <template slot-scope="scope">
                        <b-badge class="mr-1" variant="light">{{ scope.row.taskId }}</b-badge>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="taskDefinitionKey" show-overflow-tooltip label="节点编号" min-width="180">
                    <template slot-scope="scope">
                        <b-badge class="mr-1" variant="success">{{ scope.row.taskDefinitionKey }}</b-badge>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="createTime" :formatter="formatterCreateTime" show-overflow-tooltip
                    label="开始时间" min-width="180"></el-table-column>
                <el-table-column align="center" prop="suspended" label="状态" min-width="80">
                    <template slot-scope="scope">
                        <div v-if="scope.row.suspended == true" class="symbol symbol-30 symbol-circle symbol-light-danger">
                            <span class="symbol-label font-size-h8">挂起</span>
                        </div>
                        <div v-else class="symbol symbol-30 symbol-circle symbol-light-primary">
                            <span class="symbol-label font-size-h8">激活</span>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column align="center" prop="tenantId" label="租户" min-width="80"></el-table-column>
                <el-table-column align="left" prop="description" show-overflow-tooltip label="描述"></el-table-column>
                <el-table-column align="center" label="操作" fixed="left" width="380">
                    <template slot-scope="scope">
                        <!-- <el-dropdown>
                            <span class="el-dropdown-link">
                                监控<i class="el-icon-arrow-down el-icon--right"></i>
                            </span>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item @click.native="showLcProcessInstance(scope.row)">流程监控</el-dropdown-item>
                                <el-dropdown-item @click.native="showLcProcessInstanceBase64(scope.row)">活动图</el-dropdown-item>
                                <el-dropdown-item @click.native="initLcApprovalWin(scope.row)">审批记录</el-dropdown-item>
                                <el-dropdown-item @click.native="getLcTaskDetail(scope.row)">详情</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>&nbsp;
                        <el-dropdown>
                            <span class="el-dropdown-link">
                                操作审批人<i class="el-icon-arrow-down el-icon--right"></i>
                            </span>                        
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item @click.native="setAssignee(scope.row)">转办</el-dropdown-item>
                                <el-dropdown-item @click.native="delegateTask(scope.row)">委派</el-dropdown-item>
                                <el-dropdown-item @click.native="setOwner(scope.row)">设置任务所属人</el-dropdown-item>
                                <el-dropdown-item @click.native="addGroupUser(scope.row)">添加组成员</el-dropdown-item>
                                <el-dropdown-item @click.native="deleteGroupUser(scope.row)">移除组成员</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                        &nbsp;
                        <el-dropdown>
                            <span class="el-dropdown-link">
                                操作<i class="el-icon-arrow-down el-icon--right"></i>
                            </span>      
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item @click.native="endProcess(scope.row)">终止实例</el-dropdown-item>
                                <el-dropdown-item @click.native="initLcTaskJumpWin(scope.row)">跳转</el-dropdown-item>
                                <el-dropdown-item @click.native="initLcTaskBackActiviImplWin(scope.row)">驳回</el-dropdown-item>
                                <el-dropdown-item @click.native="initNextNodeWin(scope.row)">提交</el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                        &nbsp; -->
                        <button class="btn btn-link" title="流程监控" @click="showLcProcessInstance(scope.row)">流程监控</button>
                        <button class="btn btn-link" title="活动图"
                            @click="showLcProcessInstanceBase64(scope.row)">活动图</button>
                        <button class="btn btn-link" title="审批记录" @click="initLcApprovalWin(scope.row)">审批记录</button>
                        <button class="btn btn-link" title="详情" @click="getLcTaskDetail(scope.row)">详情</button>

                        <button class="btn btn-link" title="转办" @click="setAssignee(scope.row)">转办</button>
                        <button class="btn btn-link" title="委派" @click="delegateTask(scope.row)">委派</button>
                        <button class="btn btn-link" title="设置任务所属人" @click="setOwner(scope.row)">设置任务所属人</button>
                        <button class="btn btn-link" title="添加组成员" @click="addGroupUser(scope.row)">添加组成员</button>
                        <button class="btn btn-link" title="移除组成员" @click="deleteGroupUser(scope.row)">移除组成员</button>

                        <button class="btn btn-link" title="终止实例" @click="endProcess(scope.row)">终止实例</button>
                        <button class="btn btn-link" title="跳转" @click="initLcTaskJumpWin(scope.row)">跳转</button>
                        <button class="btn btn-link" title="驳回" @click="initLcTaskBackActiviImplWin(scope.row)">驳回</button>

                        <button class="btn btn-link" title="提交" @click="initNextNodeWin(scope.row)">提交</button>
                        <!-- <button class="btn btn-link" title="办理任务" @click="showDynamicActiviImpl(scope.row)">办 理</button> -->
                        <button class="btn btn-link" title="催办任务" @click="urge(scope.row)">催 办</button>

                        <button class="btn btn-link" v-if="scope.row.suspended == true" title="激活" @click="activateProcess(scope.row)">激 活</button>
                        <button class="btn btn-link"  v-if="scope.row.suspended == false" title="挂起" @click="suspendProcess(scope.row)">挂 起</button>
                        
                        <button class="btn btn-link" title="根据自定义节点流转" @click="customJump(scope.row)">自定义节点流转</button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="block">
                <el-pagination hide-on-single-page @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="pageNo" :page-sizes="[5, 10, 30, 50]" :page-size="pageSize"
                    layout="->,total, sizes, prev, pager, next, jumper" :total="totalCount">
                </el-pagination>
            </div>
        </div>
        <LcTaskDetail ref="lcTaskDetailRef"></LcTaskDetail>
        <LcApprovalWin ref="lcApprovalRef"></LcApprovalWin>
        <LcTaskHisWin ref="lcTaskHisWinRef"></LcTaskHisWin>
        <LcTaskImageWin ref="lcTaskImageWinRef"></LcTaskImageWin>
        <LcACGWin ref="lcACGWinRef" @change="doDeleteGroupUser"></LcACGWin>
        <ZBUserSelect ref="ZBUserSelectRef" :userOption="{ userOption }" @change="doSetAssignee"></ZBUserSelect>
        <!--采用父窗口关闭传递的方法-->
        <WPUserSelect ref="WPUserSelectRef" :userOption="{ userOption }" @change="doDelegateTask"></WPUserSelect>
        <!--采用父窗口关闭传递的方法-->
        <GSRUserSelect ref="GSRUserSelectRef" :userOption="{ userOption }" @change="doSetOwner"></GSRUserSelect>
        <!--采用父窗口关闭传递的方法-->
        <TJZCYUserSelect ref="TJZCYUserSelectRef" :userOption="{ userOption }" @change="doAddGroupUser"></TJZCYUserSelect>
        <!--采用父窗口关闭传递的方法-->
        <SearchUserSelect ref="SearchUserSelectRef" :userOption="{ userOption }" @change="doSetSearch"></SearchUserSelect>
        <LcDPRWin ref="LcDPRWinRef" @change="doSetGroupSearch"></LcDPRWin>
        <LcTaskJumpWin ref="lcTaskJumpWinRef" @change="search"></LcTaskJumpWin>
        <LcTaskRejectWin ref="lcTaskRejectWinRef" @change="search"></LcTaskRejectWin>
        <LcTaskSubmitWin ref="lcTaskSubmitWinRef" @change="search"></LcTaskSubmitWin>
        
    </div>
</template>
  
<script>
import { SET_BREADCRUMB } from "@/store/breadcrumbs.module";
import Swal from "sweetalert2";
import apiUtil from "@/core/util/apiUtil.js";
import LcTaskDetail from "@/view/workflow/lc-components/lc-task-detail.vue";
import LcApprovalWin from "@/view/workflow/lc-components/lc-approval-win.vue";
import LcTaskHisWin from "@/view/workflow/lc-components/lc-image-win.vue";
import LcTaskImageWin from "@/view/workflow/lc-components/lc-task-image-win.vue";
import LcACGWin from "@/view/workflow/lc-components/lc-acg-win.vue";
import LcDPRWin from "@/view/workflow/lc-components/lc-dpr-win.vue";
import ZBUserSelect from "@/components/user-select.vue";
import WPUserSelect from "@/components/user-select.vue";
import GSRUserSelect from "@/components/user-select.vue";
import TJZCYUserSelect from "@/components/user-select.vue";
import SearchUserSelect from "@/components/user-select.vue";
import LcTaskJumpWin from "@/view/workflow/lc-task/lc-task-jump-win.vue";
import LcTaskRejectWin from "@/view/workflow/lc-task/lc-task-reject-win.vue";
import LcTaskSubmitWin from "@/view/workflow/lc-task/lc-task-submit-win.vue";

import { handleNotify, handleAlert, handleConfirm, showWating, closeWating, dateformat } from "@/core/util/jehcUtil.js";
export default {
    data() {
        return {
            searchForm: { 
                taskName: "", owner: "", ownerText: "", transactors: "", transactorsText: "", 
                candidatesText:"",candidates:"",groupText:"",group:"",
                taskId: "", businessKey: "", taskDefinitionKey: "", suspended: "", instanceId: "",taskType:"" ,tenantId:"",
            },
            dataList: [],
            userOption: { allowMultiSelect: false },
            currentTaskRow: {},//当前任务行记录
            sels: [], //当前选框选中的值
            pageNo: 1,      // 默认当前是第一页
            pageSize: 5,    // 当前每页的数据是5条
            totalCount: 0   // 总数默认为0
        }
    },
    components: {
        LcTaskDetail,
        LcApprovalWin,
        LcTaskHisWin,
        LcTaskImageWin,
        ZBUserSelect,
        WPUserSelect,
        GSRUserSelect,
        TJZCYUserSelect,
        LcACGWin,
        SearchUserSelect,
        LcDPRWin,
        LcTaskJumpWin,
        LcTaskRejectWin,
        LcTaskSubmitWin,
    },
    mounted() {
        this.$store.dispatch(SET_BREADCRUMB, [{ title: "运行任务" }]);
        this.initList();   // 按当前的页号和每页的数据量进行查询
    },
    methods: {
        initList() {
            showWating({ renderBody: "tableBody" });
            var params = {};
            params.usePageNo = true;//采用第几页进行分页（兼容）
            params.pageSize = this.pageSize;//页面显示记录条数，在页面显示每页显示多少项的时候
            params.pageNo = this.pageNo;//开始的记录序号  
            params.start = (this.pageNo - 1) * this.pageSize;//增加分页通过第几条数据开始分页方式
            params.searchJson = JSON.stringify(this.searchForm);//为form元素     
            apiUtil.queryPage(process.env.VUE_APP_WORKFLOW_API + "/lcTask/list", params).then(({ data }) => {
                this.dataList = data.data;//给结果集赋值
                this.totalCount = data.total;// 获取当前数据的总数    
            });
        },

        handleSelectionChange(sels) {//获取选中的值
            this.sels = sels;
            console.log("选中的值", sels.map((item) => item.lcProductId));
        },
        addLcProduct() {//新建
            this.$refs.LcProductAddRef.showModal()
        },
        updateLcProduct() {// 更新
            if (this.sels.length != 1) {
                handleAlert("请选择一条数据", "warning", 3)
                return;
            }
            let id = this.sels.map((item) => item.lcProductId);
            this.$refs.LcProductUpdateRef.showModal(id);
        },
        delLcProduct() { // 删除
            if (this.sels.length === 0) {
                handleAlert("请选择删除的数据", "warning", 3)
                return;
            }
            // 删除前提示
            this.$confirm("确认删除记录吗?", "提示", { type: "warning", }).then(() => {
                let ids = this.sels.map((item) => item.lcProductId);
                // 根据后台想要的参数格式选择
                // console.log(ids.join(",")); //1,2,3,4
                // console.log(ids); //[1,2,3,4]
                apiUtil.delete(process.env.VUE_APP_WORKFLOW_API + "/lcProduct/delete?lcProductId=" + ids.join(",")).then(data => {
                    if (data.data.success) {
                        handleAlert("删除成功", "success", 3);
                        this.search();
                    } else {
                        handleAlert("删除失败", "error", 3);
                    }
                });
            }).catch(() => { });//注意这里，这里是重点！！！;        
        },
        handleSizeChange(val) { // 修改每页所存数据量的值所触发的函数
            this.pageSize = val;  // 修改页的大小
            this.initList();       // 按新的pageNo和pageSize进行查询
        },
        handleCurrentChange(val) { // 修改当前页所触发的函数
            this.pageNo = val;       // 更新当前的页            
            this.initList();          // 按新的pageNo和pageSize进行查询
        },
        search() {
            this.pageNo = 1;       // 更新当前的页
            this.initList();          // 按新的pageNo和pageSize进行查询
        },
        resetAll() {
            Object.assign(this.$data.searchForm, this.$options.data().searchForm);
            this.search();
        },
        getLcProductDetail(row) {
            this.$refs.LcProductDetailRef.showModal(row.lcProductId);
        },
        formateDhms(row) {
            let timestamp = row.durationInMillis;
            if (timestamp) {
                timestamp = timestamp / 1000;
                var result = '';
                if (timestamp >= 86400) {
                    var days = Math.floor(timestamp / 86400);
                    timestamp = timestamp % 86400;
                    result = days + ' 天';
                    if (timestamp > 0) {
                        result += ' ';
                    }
                }
                if (timestamp >= 3600) {
                    var hours = Math.floor(timestamp / 3600);
                    timestamp = timestamp % 3600;
                    result += hours + ' 小时';
                    if (timestamp > 0) {
                        result += ' ';
                    }
                }
                if (timestamp >= 60) {
                    var minutes = Math.floor(timestamp / 60);
                    timestamp = timestamp % 60;
                    result += minutes + ' 分钟';
                    if (timestamp > 0) {
                        result += ' ';
                    }
                }
                result += parseInt(timestamp) + ' 秒';
                return result;
            }
            return "";
        },
        formatterCreateTime(row, column) {
            return dateformat(row.createTime);
        },
        formatterEndTime(row, column) {
            return dateformat(row.endTime);
        },
        getLcTaskDetail(row) {
            this.$refs.lcTaskDetailRef.showModal(row.taskId);
        },
        initLcApprovalWin(row) {//审批记录
            this.$refs.lcApprovalRef.showModal(row.processInstanceId);
        },
        showLcProcessInstance(row) {//流程监控
            this.$refs.lcTaskHisWinRef.showModal(row);
        },
        urge(row) {//催办
            let taskId = row.taskId
            this.$bvModal.msgBoxConfirm("确定催办该任务？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, behavior: 100 };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/approve", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },
        activateProcess(row) {//激活
            let taskId = row.taskId
            this.$bvModal.msgBoxConfirm("确定激活该流程？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, behavior: 130 };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/activateProcess", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },    
        suspendProcess(row) {//挂起
            let taskId = row.taskId
            this.$bvModal.msgBoxConfirm("确定挂起该流程？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, behavior: 120 };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/suspendProcess", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },  
           
        showDynamicActiviImpl(row) {//办理任务
            let taskId = row.taskId
        },
        showLcProcessInstanceBase64(row) {//流程活动图
            this.$refs.lcTaskImageWinRef.showModal(row);
        },
        endProcess(row) {
            let taskId = row.taskId
            this.$bvModal.msgBoxConfirm("确定终止流程实例？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, behavior: 100 };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/termination", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },
        initLcTaskJumpWin(row) {//跳转            
            this.$refs.lcTaskJumpWinRef.showModal(row);
        },
        initLcTaskBackActiviImplWin(row) {//驳回
            this.$refs.lcTaskRejectWinRef.showModal(row);
        },
        initNextNodeWin(row) {//提交
            this.$refs.lcTaskSubmitWinRef.showModal(row);
        },
        setAssignee(row) {//转办
            this.userOption.allowMultiSelect = false;
            this.$refs.ZBUserSelectRef.showModal(row);
            this.currentTaskRow = row;
        },
        doSetAssignee(data) {//执行转办
            let ids = data.map((item) => item.id);
            let names = data.map((item) => item.name);
            let taskId = this.currentTaskRow.taskId;
            this.$bvModal.msgBoxConfirm("确定将该任务【" + this.currentTaskRow.name + "】转办给【" + names.join(",") + "】？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, mutilValue: ids.join(",") };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/transfer", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },
        delegateTask(row) {//委派
            this.userOption.allowMultiSelect = false;
            this.$refs.WPUserSelectRef.showModal(row);
            this.currentTaskRow = row;
        },
        doDelegateTask(data) {
            let ids = data.map((item) => item.id);
            let name = data.map((item) => item.name);
            let taskId = this.currentTaskRow.taskId;
            this.$bvModal.msgBoxConfirm("确定将该任务【" + this.currentTaskRow.name + "】委派给【" + name.join(",") + "】？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, ownerId: ids.join(",") };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/delegateTask", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },
        setOwner(row) {//设置任务所属人
            this.userOption.allowMultiSelect = false;
            this.$refs.GSRUserSelectRef.showModal(row);
            this.currentTaskRow = row;
        },
        doSetOwner(data) {
            let ids = data.map((item) => item.id);
            let names = data.map((item) => item.name);
            let taskId = this.currentTaskRow.taskId;
            this.$bvModal.msgBoxConfirm("确定将该任务【" + this.currentTaskRow.name + "】归属到【" + names.join(",") + "】名下？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, mutilValue: ids.join(",") };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/setOwner", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },
        addGroupUser(row) {//添加组成员
            this.userOption.allowMultiSelect = false;
            this.$refs.TJZCYUserSelectRef.showModal(row);
            this.currentTaskRow = row;
        },
        doAddGroupUser(data) {
            let ids = data.map((item) => item.id);
            let names = data.map((item) => item.name);
            let taskId = this.currentTaskRow.taskId;
            this.$bvModal.msgBoxConfirm("确定将向任务【" + this.currentTaskRow.name + "】添加组成员【" + names.join(",") + "】？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, mutilValue: ids.join(",") };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/addGroupUser", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },
        deleteGroupUser(row) {//移除组成员
            this.$refs.lcACGWinRef.showModal(row);
            this.currentTaskRow = row;
        },
        doDeleteGroupUser(data) {
            console.log("data",data);
            let ids = data.userId;
            let names = data.name;
            let taskId = this.currentTaskRow.taskId;
            this.$bvModal.msgBoxConfirm("确定移除该任务【" + this.currentTaskRow.name + "】下组成员【" + names + "】？", {
                title: '提示',
                size: 'sm',
                buttonSize: 'sm',
                okVariant: 'success',
                okTitle: '确定',
                cancelTitle: '取消',
                headerClass: 'p-2 border-bottom-0',
                footerClass: 'p-2 border-top-0',
                hideHeaderClose: false,
                centered: true
            }).then(value => {
                if (value) {
                    let params = { taskId: taskId, mutilValue: ids };
                    apiUtil.post(process.env.VUE_APP_WORKFLOW_API + "/lcTask/deleteGroupUser", params).then(data => {
                        if (data.data.success) {
                            handleAlert("操作成功", "success", 3);
                            this.search();
                        } else {
                            handleAlert("操作失败", "error", 3);
                        }
                    });
                }
            }).catch(err => {
            })
        },
        initApprover(flag){//初始化查询条件
            if(flag == 0 || flag == 1 || flag == 2){
                this.userOption.allowMultiSelect = false;
                this.$refs.SearchUserSelectRef.showModal();
            }
            if(flag == 3){//组（通过部门 岗位 角色）
                
            }
        },
        doSetSearch(data){//设置查询条件非组
            this.searchForm.ownerText = "";
            this.searchForm.owner = "";
            this.searchForm.transactorsText = "";
            this.searchForm.transactors = "";
            this.searchForm.candidatesText = "";
            this.searchForm.candidates = "";
            this.searchForm.groupText = "";
            this.searchForm.group = "";
            let userId = data[0].id;
            let userName = data[0].name;
            let flag = this.searchForm.taskType;           
            if(flag == '0'){
                this.searchForm.ownerText = userName
                this.searchForm.owner = userId
            }
            if(flag == '1'){
                this.searchForm.transactorsText = userName
                this.searchForm.transactors =userId
            }
            if(flag == '2'){
                this.searchForm.candidatesText = userName
                this.searchForm.candidates = userId
            }
        },
        doSetGroupSearch(data){//设置查询条件组
            this.searchForm.ownerText = "";
            this.searchForm.owner = "";
            this.searchForm.transactorsText = "";
            this.searchForm.transactors = "";
            this.searchForm.candidatesText = "";
            this.searchForm.candidates = "";
            this.searchForm.groupText = "";
            this.searchForm.group = "";
            let groupText = data[0].text;
            let group = data[0].id;
            let flag = this.searchForm.taskType;    
            console.log(groupText,group,data);       
            if(flag == 3){
                this.searchForm.groupText = groupText
                this.searchForm.group = group;
            }
        },
        resetApprover(flag){
            if(flag == 0){
                this.searchForm.ownerText = "";
                this.searchForm.owner = "";
            }
            if(flag == 1){
                this.searchForm.transactorsText = "";
                this.searchForm.transactors = "";
            }
            if(flag == 2){
                this.searchForm.candidatesText = "";
                this.searchForm.candidates = "";
            }
            if(flag == 3){
                this.searchForm.groupText = "";
                this.searchForm.group = "";
            }
        },
        initOrgWin(){
            this.$refs.LcDPRWinRef.showModal();
        },
        customJump(row){
            handleAlert("敬请期待", "warn", 3);
        },
    },
};
</script>
<style scoped>.el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
}

.el-icon-arrow-down {
    font-size: 12px;
}</style>